namespace ai_library
{
	public class ActionFactoryException : System.Exception
	{
		protected string message;
		public ActionFactoryException(string message) { this.message = message; }
		public override string Message { get { return message; } }
		public override string ToString() { return "Action Factory Exception: " + message; }
	}

	public static class ActionFactory<T> where T : IEntity, IEntityStateMachine<T>
	{
		public static IAction<T> Get(ActionTypes actionType)
		{
			IAction<T> retAction = null;

			switch (actionType)
			{
			case ActionTypes.ChangeState_Idle:
				retAction = new ChangeStateAction<T>(StateTypes.IdleState, StateTypes.NoState);
				break;

			case ActionTypes.ChangeState_Wander:
				retAction = new ChangeStateAction<T>(StateTypes.WanderState, StateTypes.NoState);
				break;

			case ActionTypes.SendMsgRand:
				retAction = new SendMessageToRandomAgentAction<T>(MessageTypes.Default);
				break;
			}

			if (retAction == null)
				throw new ActionFactoryException("ActionType " + actionType + " not defined in factory");

			return retAction;
		}
	}
}

